﻿/*
 * 由SharpDevelop创建。
 * 用户： Administrator
 * 日期: 2024/12/1
 * 时间: 13:36
 * 
 * 要改变这种模板请点击 工具|选项|代码编写|编辑标准头文件
 */
using System;
using System.IO;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using CSharpWin_JD.CaptureImage;
using System.Reflection; 

namespace Capture
{
	/// <summary>
	/// Description of MainForm.
	/// </summary>
	public partial class MainForm : Form
	{
		public MainForm()
		{
			//
			// The InitializeComponent() call is required for Windows Forms designer support.
			//
			 AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
			 
			InitializeComponent();
			
			string inipath=Directory.GetCurrentDirectory()+"\\setting.ini"; 
			int x=int.Parse(iniHelper.Read("Capture","left",inipath));
			int y=int.Parse(iniHelper.Read("Capture","top",inipath));
			this.Location=new Point(x,y);
			 
			int w=int.Parse(iniHelper.Read("Capture","width",inipath));
			int h=int.Parse(iniHelper.Read("Capture","height",inipath));
			this.Size=new Size(w,h);
			
			
			//
			// TODO: Add constructor code after the InitializeComponent() call.
			//
		}
		 
		private Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
        {
            //默认命名空间+文件夹名+.[注意]
            string resourceName = "Capture." + new AssemblyName(args.Name).Name + ".dll";

            // LogHelper.Debug("在加载资源：" + resourceName);
            using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName))
            {
                if (stream != null)
                {
                    byte[] assemblyData = new byte[stream.Length];
                    stream.Read(assemblyData, 0, assemblyData.Length);
                    return Assembly.Load(assemblyData);
                }

                return null;
            }
        }

		
		void PictureBox1Click(object sender, EventArgs e)
		{
			CaptureImageTool capture = new CaptureImageTool();
            if (capture.ShowDialog() == DialogResult.OK)
            {
                Image image = capture.Image;
                Clipboard.SetImage(image);
            }
		}
		void Timer1Tick(object sender, EventArgs e)
		{
			string inipath=Directory.GetCurrentDirectory()+"\\setting.ini"; 
			string color=iniHelper.Read("Topbar","backcolor",inipath);
			this.BackColor =ColorTranslator.FromHtml(color); 
		}
		
		
		
	}
}
